home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / ErrorDaemon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  3.2 KB  |  93 lines  |  [TEXT/KAHL]

  1. /* ErrorDaemon.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #include "ErrorDaemon.h"
  31. #include "Memory.h"
  32.  
  33.  
  34. struct ErrorDaemonRec
  35.     {
  36.         float                        MaxClampValue;
  37.     };
  38.  
  39.  
  40. /* get a new error daemon */
  41. ErrorDaemonRec*            NewErrorDaemon(void)
  42.     {
  43.         ErrorDaemonRec*        Daemon;
  44.  
  45.         Daemon = (ErrorDaemonRec*)AllocPtrCanFail(sizeof(ErrorDaemonRec),"ErrorDaemonRec");
  46.         if (Daemon == NIL)
  47.             {
  48.              FailurePoint1:
  49.                 return NIL;
  50.             }
  51.         Daemon->MaxClampValue = 0;
  52.         return Daemon;
  53.     }
  54.  
  55.  
  56. /* dispose of the error daemon */
  57. void                                DisposeErrorDaemon(ErrorDaemonRec* Daemon)
  58.     {
  59.         CheckPtrExistence(Daemon);
  60.         ReleasePtr((char*)Daemon);
  61.     }
  62.  
  63.  
  64. /* report a new clamping value.  value should be positive and greater than 1 */
  65. void                                ErrorDaemonReportClamping(ErrorDaemonRec* Daemon, float ClampedValue)
  66.     {
  67.         CheckPtrExistence(Daemon);
  68.         ERROR(ClampedValue < 0,PRERR(AllowResume,
  69.             "ErrorDaemonReportClamping:  passed value is less than zero"));
  70.         ERROR(ClampedValue <= 1,PRERR(AllowResume,
  71.             "ErrorDaemonReportClamping:  passed value is not greater than one"));
  72.         if (Daemon->MaxClampValue < ClampedValue)
  73.             {
  74.                 Daemon->MaxClampValue = ClampedValue;
  75.             }
  76.     }
  77.  
  78.  
  79. /* return True if clamping occurred */
  80. MyBoolean                        ErrorDaemonDidClampingOccur(ErrorDaemonRec* Daemon)
  81.     {
  82.         CheckPtrExistence(Daemon);
  83.         return (Daemon->MaxClampValue > 1);
  84.     }
  85.  
  86.  
  87. /* obtain the maximum clamping value */
  88. float                                ErrorDaemonGetMaxClamping(ErrorDaemonRec* Daemon)
  89.     {
  90.         CheckPtrExistence(Daemon);
  91.         return Daemon->MaxClampValue;
  92.     }
  93.